package cn.jbolt.admin.userconfig;

import cn.jbolt.core.enumutil.JBoltEnum;
import cn.jbolt.core.model.UserConfig;
import cn.jbolt.core.service.JBoltUserConfigService;
import cn.jbolt.extend.userconfig.ExtendUserConfigKey;

public class UserConfigService extends JBoltUserConfigService {
    @Override
    protected void processExtendUserConfig(UserConfig userConfig) {
        ExtendUserConfigKey extendUserConfigKey = JBoltEnum.getEnumObjectByValue(ExtendUserConfigKey.class,userConfig.getConfigKey());
        if(extendUserConfigKey == null){
           throw new RuntimeException("ExtendUserConfigKey 未定义:"+userConfig.getConfigKey());
        }
        boolean success = true;
        switch (extendUserConfigKey){
            //case xxx:
            //    userConfig.setValueType(UserConfigValueType.TYPE_STRING);
            //    userConfig.setName("xxx");
            //    break;
            //default:
            //    success = false;
            //    break;
        }
        if(!success){
            throw new RuntimeException("ExtendUserConfigKey 未定义:"+userConfig.getConfigKey());
        }

    }
}
